---
title: "Tunisian Unemployment Map, 2014"
author: Zohra Rezgui
date: 2017
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: scroll
social: [ "facebook", "pinterest", "linkedin" ]
theme: flatly
source_code: embed
navbar:
- { title: "Home", href: "https://zohrarezgui.github.io", align: left }
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(raster)
library(maptools)
library(readxl)
library(leaflet)
library(ggplot2)
library(plotly)
```
Column {data-width=650}
-----------------------------------------------------------------------
### Map
```{r, fig.height=5}
delg <- getData(name = "GADM", country="TUN" , level=2)
Unipop=read_excel("../data/Uni level Pop.xlsx", sheet = 2, col_names = T)
hascs = read_excel("../data/Delegation HASC.xlsx", sheet = 1, col_names = T)
Uni_Unemp = read_excel("../data/Unemployed Uni.xlsx", sheet = 1, col_names = T)
i = match(Uni_Unemp$Régions, Unipop$Région)
Uni_Unemp$Uni_population = Unipop$Valeur[i]
Uni_Unemp$Unemployed_proportion = round((Uni_Unemp$`2014`/Uni_Unemp$Uni_population)*100,3)
j =match(Uni_Unemp$Régions, hascs$Regions)
Uni_Unemp$HASC = hascs$HASC[j]
k = match(delg@data$HASC_2, Uni_Unemp$HASC)
delg@data$prop= Uni_Unemp$Unemployed_proportion[k]
my_popup <- paste0("",delg@data$NAME_2,""," (",round(delg@data$prop,3),"%)")
MyPaletteColor <- colorBin("YlOrRd", domain=(3):45,bins=11,na.color = "white")
mm<-leaflet(data = delg) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = ~MyPaletteColor(delg@data$prop),
fillOpacity = 0.8,
color = "#BDBDC3",
weight = 1,
popup = my_popup)%>%
addLegend(pal = MyPaletteColor, values = ~delg@data$prop, opacity = 0.7, title = NULL,position = "bottomright")
mm
```
Column {data-width=350}
-----------------------------------------------------------------------
### Unemployment Boxplot
```{r, fig.height=5}
colnames(Uni_Unemp)[1]<- "Delegation"
colnames(Uni_Unemp)[3]<- "Unemployed Population with higher education"
colnames(Uni_Unemp)[4]<- "Population with higher education"
colnames(Uni_Unemp)[5]<- "% Unemployed with higher education"
g= ggplot(data = Uni_Unemp, aes(x = as.factor(Region), y= Uni_Unemp$`% Unemployed with higher education`, fill= Region))+
geom_boxplot() +xlab("") + ylab("") + ggtitle("% Unemployment with Higher Education in Delegations by Region")+
scale_fill_brewer(palette = "Set2")+ theme(legend.position = "none", plot.title = element_text(size = 12))
ggplotly(g)
```
### Data Preview (Source: National Census, 2014, National Institute of Statistics, Tunisia)
```{r, fig.height=2}
DT::datatable(Uni_Unemp[1:10,c(1, 3:5)])
```